//
//  NavigationBarHeightHelper.swift
//  Kosspot
//
//  Created by 李鑫 on 2025/7/2.
//

import SwiftUI

struct NavigationBarHeightHelper {
    static func getTotalHeight() -> CGFloat {
        guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
              let window = windowScene.windows.first else {
            return 0
        }
        
        let statusBarHeight = window.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
        let navigationBarHeight = UINavigationController().navigationBar.frame.height
        
        return statusBarHeight + navigationBarHeight
    }
}

extension View {
    func getNavigationBarTotalHeight() -> CGFloat {
        return NavigationBarHeightHelper.getTotalHeight()
    }
}
